<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>工程泛联客/账户绑定</title>
	<jsp:include page="../../../main/mp/inc.jsp"	/>
	<style type="text/css">
		.jqm-content > h2 {
			color: #3eb249;
			background-color: transparent;
			border-bottom: 1px solid #ddd;
			font-size: 1.1em;
			padding-bottom: .2em;
			margin: 0 0 .7375em;
		}
		.round_photo{
			width:30px;
			height:30px;
			border:1px solid #ddddde;
			-moz-border-radius: 29px;
			-webkit-border-radius: 29px;
			border-radius:29px;
		}
		#authcode_contain div.ui-btn {
			width: 33%;
			padding: 0.7em;
			margin-top: 0.8em;
			float: right;
		}
		#authcode_contain div.ui-input-text{
			width:50%;
			float: left;
		}
		#register_page_person_confirm{
			padding-left: 16px;
			padding-right: 16px;
		}
	</style>
	<script>
		//所有的cookie操作都在后台进行。
		$(function() {
			$("[data-role='navbar']").navbar();
			$("[data-role='header'], [data-role='footer']").toolbar();

			$(document).on("pageshow", "[data-role='page']", function () {
				try {
					WeixinJSBridge.call('hideToolbar');
					//WeixinJSBridge.call('hideOptionMenu');
				} catch (e) {

				}
			});


			$("#login_page_confirm").click(function (e) {
				$("#login_page_confirm").hide();
				$.mobile.loading("show", {
					text: "正在绑定，请稍后...",
					textVisible: true,
					theme: "b",
					textonly: false,
					html: ""
				});
				var actionUrl = $("form#login_form").attr("action");
				var formData = $("form#login_form").serialize();
				ajax_action(actionUrl, formData, {
					errorHandle:function(data){
						var message=eval('(' + data.responseText + ')');
						$("#login_page_confirm").show();
						hide();
						alert(message.result.errorMessage);
						//alert("绑定失败");
					}
				}, function (data) {
					hide();
					if (data.result.errorCode == 1 || data.result.errorCode == "1") {
						//根据返回的值设置cookie
						alert(data.result.errorMessage);
						//SetCookie("webUsername",data.data.webUsername);
						//location.replace("homepage!index.action");
						location.replace("index.action");
					} else {
						delCookie("webUsername");
						$("#login_page_confirm").show();
						alert(data.result.errorMessage);
					}
				});

			});


			//查看登录的账户信息
			function readCookie() {
				alert("登陆账户：" + getCookie("u"));
			}

			//+ " 绑定信息：" + getCookie("webOpenId")
			function delelteCookie() {
				readCookie();
				delCookie("u");
				delCookie("digest");
				alert("清除成功，请退出该页面重新进入系统。");
			}
		})



	</script>


</head>
<body>
<!-- class="jqm-demos" -->
<div data-role="page" id="page-main" data-theme="a">
	<div class="ui-content jqm-content jqm-fullwidth" role="main">
		<h2 id="Inline"><img alt="" onclick="readCookie()" src="${headimgurl}" class="round_photo">  ${nickname}，恭候多时。   </h2>

		<input type="hidden" id="openId" value="${openId}" />
		<c:if test="users == null">
			<h4 id="Inline"><i class="fa fa-hand-o-right"></i>  登录</h4>
			<form method="post" id="login_form" action="account/connectMp.action" data-ajax="false">
				<input type="hidden" name="openId" value="${openId}" />
				<input type="text" name="username" value="" placeholder="支持用户手机号">
				<input type="password" name="password" value="" autocomplete="off" placeholder="请输入密码">
			</form>
			<a href="#" id="login_page_confirm" class="ui-btn-b ui-btn ui-icon-check ui-corner-all ">登录</a>
			<a href="ajax-users!resetinput.action" data-ajax="false">忘记密码？</a>
			<a href="ajax-users!experience.action?openId=<s:property value="openId"/>" style="float: right;" data-ajax="false">体验注册</a>
			<hr />
			<hr style="width:100%" />
		</c:if>
		<c:if test="users!=null">
			<h2 id="Inline">您的微信已经绑定工程泛联客账号。 </h2>

			<p>请点击 <a href="users!reset.action?openId=<s:property value="openId"/>"  data-ajax="false" > 设置我的账号 </a> 或 ↓进入首页。</p>
		</c:if>


	</div><!-- /content -->

	<div data-role="footer" data-position="fixed" data-theme="a">
		<div data-role="navbar" data-iconpos="left" >
			<ul>
				<li><a href="javascript:void(0)" id="window_close" data-ajax="false" data-icon="delete">关闭页面</a></li>
				<li><a href="index.action" data-ajax="false"  data-icon="home" >进入首页</a></li>
			</ul>
		</div><!-- /navbar -->
	</div><!-- /footer -->
</div><!-- /page -->

<!-- -------------------------------------------------------------------------------- -->
</body>
</html>